/* Copyright  2009-2010
   @Author
   Richard Changde Yin            e-mail yinchangde@hotmail.com

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

/**
 *@filename: direct_ref.h
 */
#ifndef _ITEM_DIRECT_REF_H_
#define _ITEM_DIRECT_REF_H_

#include <item/ref.h>

/*
  The same as Item_ref, but get value from val_* family of method to get
  value of item on which it referred instead of result* family.
*/
class Item_direct_ref :public Item_ref
{
public:
  Item_direct_ref(Name_resolution_context *context_arg, Item **item,
                  const char *table_name_arg,
                  const char *field_name_arg,
                  bool alias_name_used_arg= false)
    :Item_ref(context_arg, item, table_name_arg,
              field_name_arg, alias_name_used_arg)
  {}
  /* Constructor need to process subselect with temporary tables (see Item) */
  Item_direct_ref(Session *session, Item_direct_ref *item)
                 : Item_ref(session, item) {}

  double val_real();
  int64_t val_int();
  String *val_str(String* tmp);
  db_decimal *val_decimal(db_decimal *);
  bool val_bool();
  bool is_null();
  bool get_date(COLLAPSAR_TIME *ltime,uint32_t fuzzydate);
  virtual Ref_Type ref_type()      { return DIRECT_REF; }
};

#endif /* _ITEM_DIRECT_REF_H_ */
